﻿using DAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Shop.Web.Controllers
{
    public class OrderController : Controller
    {
        // GET: Order
        public ActionResult Index(string OrderId)
        {
            //string OrderId, string CustId1, string ProductName, string ProductPrth, string Price, string Count, string IsTake, string OrderTime, string State, string IsFah
           
                OrderService.UpdateIsTake(OrderId);
                string Name = User.Identity.Name;
                var NameId = CustomerService.GetCustomer(Name);
                int CustId = NameId.Id;
                List<Order> ordermsg = OrderService.GetOrders(CustId);
                ViewBag.bg = ordermsg;
                return View();
            
          
           
        }
        public ActionResult Index1()
        {
            //string OrderId, string CustId1, string ProductName, string ProductPrth, string Price, string Count, string IsTake, string OrderTime, string State, string IsFah

            //OrderService.UpdateIsTake(OrderId);
            string Name = User.Identity.Name;
            var NameId = CustomerService.GetCustomer(Name);
            int CustId = NameId.Id;
            List<Order> ordermsg = OrderService.GetOrders(CustId);
            ViewBag.bg = ordermsg;
            return View();
        }
        /// <summary>
        /// 确认收货
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public ActionResult Update(int Id)
        {
            int a = OrderService.UpdateOrder(Id);
            if (a>0)
            {
                return Json(new {Success=true , Message="修改成功" });
            }
            else
            {
                return Json(new { Success = false, Message = "修改失败" });
            }
        }

        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public ActionResult Delete(int Id)
        {
            int a = OrderService.GetArtDel(Id);
            if (a > 0)
            {
                return Json(new { Success = true, Message = "修改成功" });
            }
            else
            {
                return Json(new { Success = false, Message = "修改失败" });
            }
        }
    }
}